<template>
  <div
    class="taskbar-item"
    :class="{ 
      'active': window.isActive, 
      'minimized': window.isMinimized 
    }"
    @click="handleClick"
    :title="window.title"
  >
    <el-icon v-if="window.icon" class="taskbar-icon">
      <component :is="window.icon" />
    </el-icon>
    <el-icon v-else class="taskbar-icon">
      <Document />
    </el-icon>
    <span class="taskbar-title">{{ window.title }}</span>
  </div>
</template>

<script setup lang="ts">
import { defineProps, defineEmits } from 'vue'
import { Document } from '@element-plus/icons-vue'
import type { AppWindow } from '@/types/app'

const props = defineProps<{
  window: AppWindow
}>()

const emit = defineEmits<{
  (e: 'click', windowId: string): void
}>()

const handleClick = () => {
  emit('click', props.window.id)
}
</script>

<style scoped>
.taskbar-item {
  display: flex;
  align-items: center;
  padding: 0 15px;
  height: 100%;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.3s;
  color: white;
  margin-right: 2px;
  min-width: 120px;
  max-width: 200px;
}

.taskbar-item.active {
  background-color: rgba(255, 255, 255, 0.2);
  border-bottom-color: var(--el-color-primary);
}

.taskbar-item.minimized {
  opacity: 0.7;
}

.taskbar-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.taskbar-icon {
  margin-right: 8px;
  font-size: 16px;
}

.taskbar-title {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
</style> 